package com.shen;

import java.util.Scanner;

/**
 * Author:shen
 * CreateDate:2020/5/24.
 * Function:
 */
public class Demo01 {
    static Scanner scanner=new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println("请输入第一个字符串：");
       String str01= scanner.nextLine();
        System.out.println("请输入第二个字符串：");
        String str02= scanner.nextLine();
        if(str01.length()>str02.length()){
            System.out.println(indexOf(str01.trim(),str02.trim()));
        }else{
            System.out.println(indexOf(str02.trim(),str01.trim()));
        }
    }
    public static int indexOf(String str01,String str02){
        int i=0;//出现的次数
       while (str01.contains(str02)){//判断还存不存在
           str01=str01.substring(str01.indexOf(str02)+str02.length(),str01.length());//排除字符出现的第一次出现之前的字符
           i++;
       }
       return i;
    }
}
